﻿<navigation:Page x:Class="LEEAAttendanceControl.Views.EmployeeHours"
           xmlns:vc="clr-namespace:LEEAAttendanceControl.Codes"
           xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
           xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
           xmlns:riaControls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.DomainServices"
           xmlns:my="clr-namespace:LEEAAttendanceControl.Web.Services"
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
           xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
           xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
           mc:Ignorable="d"
           xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
           d:DesignWidth="640" d:DesignHeight="480"
           Title="Employee Hours">
    <Grid x:Name="LayoutRoot">
        <Grid.Resources>
            <vc:MinutesToHoursConverter x:Key="MinutesToHoursConverter"/>
        </Grid.Resources>
        <Grid.RowDefinitions>
            <RowDefinition Height="300"/>
            <RowDefinition Height="300"/>
        </Grid.RowDefinitions>
        
        <StackPanel Orientation="Vertical" Grid.Row="0">
            <Grid Background="#404041" HorizontalAlignment="Stretch">
                <TextBlock x:Name="EmployeesBlock" Text="Employee Hours" Foreground="White" FontSize="14" FontWeight="Bold" Margin="5,3,3,3"/>
            </Grid>

            <riaControls:DomainDataSource x:Name="HoursSummaryDataSource" AutoLoad="True" QueryName="GetHoursSummaries"
                                          LoadingData="HoursSummaryDataSource_LoadingData">
                <riaControls:DomainDataSource.DomainContext>
                    <my:LEEAContext />
                </riaControls:DomainDataSource.DomainContext>
            </riaControls:DomainDataSource>
            
            <sdk:DataGrid x:Name="EmployeesGrid" IsReadOnly="True" AutoGenerateColumns="False" MaxHeight="270"
                          ItemsSource="{Binding Data, ElementName=HoursSummaryDataSource}"
                          VerticalScrollBarVisibility="Auto" SelectionChanged="EmployeesGrid_SelectionChanged">
                <sdk:DataGrid.Columns>
                    <sdk:DataGridTemplateColumn Header="Employee Name" CanUserReorder="False" CanUserResize="True"
                                                    Width="180" IsReadOnly="True">
                        <sdk:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
                                    <TextBlock Text="{Binding FirstName}"/>
                                    <TextBlock Text=" "/>
                                    <TextBlock Text="{Binding LastName}"/>
                                </StackPanel>
                            </DataTemplate>
                        </sdk:DataGridTemplateColumn.CellTemplate>
                    </sdk:DataGridTemplateColumn>
                    <sdk:DataGridTemplateColumn Header="Total" CanUserSort="True" Width="80">
                        <sdk:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <sdk:Label Content="{Binding Total, Converter={StaticResource MinutesToHoursConverter}}"
                                           Margin="5,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Left"
                                           Height="25"/>
                            </DataTemplate>
                        </sdk:DataGridTemplateColumn.CellTemplate>
                    </sdk:DataGridTemplateColumn>
                    <sdk:DataGridTemplateColumn Header="Breaks" CanUserSort="True" Width="70">
                        <sdk:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <sdk:Label Content="{Binding Breaks, Converter={StaticResource MinutesToHoursConverter}}"
                                           Margin="5,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Left"
                                           Height="25"/>
                            </DataTemplate>
                        </sdk:DataGridTemplateColumn.CellTemplate>
                    </sdk:DataGridTemplateColumn>
                    <sdk:DataGridTemplateColumn Header="Exceptions" CanUserSort="True" Width="75">
                        <sdk:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <sdk:Label Content="{Binding Exceptions, Converter={StaticResource MinutesToHoursConverter}}"
                                           Margin="5,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Left"
                                           Height="25"/>
                            </DataTemplate>
                        </sdk:DataGridTemplateColumn.CellTemplate>
                    </sdk:DataGridTemplateColumn>
                    <sdk:DataGridTemplateColumn Header="Paid" CanUserSort="True" Width="80">
                        <sdk:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <sdk:Label Content="{Binding Paid, Converter={StaticResource MinutesToHoursConverter}}"
                                           Margin="5,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Left"
                                           Height="25"/>
                            </DataTemplate>
                        </sdk:DataGridTemplateColumn.CellTemplate>
                    </sdk:DataGridTemplateColumn>
                    <sdk:DataGridTemplateColumn Header="Overtime" CanUserSort="True" Width="70">
                        <sdk:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <sdk:Label Content="{Binding Overtime, Converter={StaticResource MinutesToHoursConverter}}"
                                           Margin="5,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Left"
                                           Height="25"/>
                            </DataTemplate>
                        </sdk:DataGridTemplateColumn.CellTemplate>
                    </sdk:DataGridTemplateColumn>
                </sdk:DataGrid.Columns>
            </sdk:DataGrid>
        </StackPanel>
        
        <StackPanel Orientation="Vertical" Grid.Row="1">
            <Grid Background="#404041" HorizontalAlignment="Stretch">
                <TextBlock x:Name="PunchBlock" Text="Employee Punches" Foreground="White" FontSize="13" FontWeight="Bold"
                           Margin="5,2,2,2"/>
            </Grid>
            
            <sdk:DataGrid x:Name="PunchesGrid" IsReadOnly="True" AutoGenerateColumns="False" MaxHeight="265"
                          VerticalScrollBarVisibility="Auto">
                <sdk:DataGrid.Columns>
                    <sdk:DataGridTemplateColumn Header="Actual IN" CanUserSort="True" Width="137">
                        <sdk:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <sdk:Label Content="{Binding ActualIN, StringFormat='dd/MM/yyyy hh:mm tt'}"
                                           Margin="5,0,0,0" VerticalAlignment="Center" Foreground="{Binding Color}"
                                           HorizontalAlignment="Left" Height="25"/>
                            </DataTemplate>
                        </sdk:DataGridTemplateColumn.CellTemplate>
                    </sdk:DataGridTemplateColumn>
                    <sdk:DataGridTemplateColumn Header="Actual OUT" CanUserSort="True" Width="137">
                        <sdk:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <sdk:Label Content="{Binding ActualOUT, StringFormat='dd/MM/yyyy hh:mm tt'}"
                                           Margin="5,0,0,0" VerticalAlignment="Center" Foreground="{Binding Color}"
                                           HorizontalAlignment="Left" Height="25"/>
                            </DataTemplate>
                        </sdk:DataGridTemplateColumn.CellTemplate>
                    </sdk:DataGridTemplateColumn>
                    <sdk:DataGridTemplateColumn Header="Rounded IN" CanUserSort="True" Width="130">
                        <sdk:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <sdk:Label Content="{Binding RoundedIN, StringFormat='dd/MM/yyyy hh:mm tt'}"
                                           Margin="5,0,0,0" VerticalAlignment="Center" Foreground="{Binding Color}"
                                           HorizontalAlignment="Left" Height="25"/>
                            </DataTemplate>
                        </sdk:DataGridTemplateColumn.CellTemplate>
                    </sdk:DataGridTemplateColumn>
                    <sdk:DataGridTemplateColumn Header="Rounded OUT" CanUserSort="True" Width="130">
                        <sdk:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <sdk:Label Content="{Binding RoundedOUT, StringFormat='dd/MM/yyyy hh:mm tt'}"
                                           Margin="5,0,0,0" VerticalAlignment="Center" Foreground="{Binding Color}"
                                           HorizontalAlignment="Left" Height="25"/>
                            </DataTemplate>
                        </sdk:DataGridTemplateColumn.CellTemplate>
                    </sdk:DataGridTemplateColumn>
                    <sdk:DataGridTemplateColumn Header="Actual Hours" CanUserSort="True" Width="87">
                        <sdk:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <sdk:Label Content="{Binding ActualHours, Converter={StaticResource MinutesToHoursConverter}}"
                                           Margin="5,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Left"
                                           Height="25" Foreground="{Binding Color}"/>
                            </DataTemplate>
                        </sdk:DataGridTemplateColumn.CellTemplate>
                    </sdk:DataGridTemplateColumn>
                    <sdk:DataGridTemplateColumn Header="Rounded Hours" CanUserSort="True" Width="92">
                        <sdk:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <sdk:Label Content="{Binding RoundedHours, Converter={StaticResource MinutesToHoursConverter}}"
                                           Margin="5,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Left"
                                           Height="25" Foreground="{Binding Color}"/>
                            </DataTemplate>
                        </sdk:DataGridTemplateColumn.CellTemplate>
                    </sdk:DataGridTemplateColumn>
                    <sdk:DataGridTemplateColumn Header="Shift" CanUserSort="True" Width="63">
                        <sdk:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <sdk:Label Content="{Binding ShiftName}" Margin="5,0,0,0" VerticalAlignment="Center"
                                           HorizontalAlignment="Left" Height="25" Foreground="{Binding Color}"/>
                            </DataTemplate>
                        </sdk:DataGridTemplateColumn.CellTemplate>
                    </sdk:DataGridTemplateColumn>
                </sdk:DataGrid.Columns>
            </sdk:DataGrid>
        </StackPanel>
    </Grid>
</navigation:Page>
